<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('录播课程列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>标题：</label>
                                <input type="text" name="title"/>
                            </li>
                            <li style="width:60%">
                            <label>栏目：</label>
							<div class="input-group col-sm-4" onclick="selectVideocategoryTree()">    
			                   <input id="treeId" name="categoryId" type="hidden" />
			                        <input class="form-control" type="text"  id="treeName" readonly="readonly"  required>
			                        <span class="input-group-addon"><i class="fa fa-search"></i></span> 
				            </div>  
                            </li>                              

                            <li>
                                <label>推荐位：</label>
                                <select name="dictPostPositions" th:with="type=${@dict.getType('dict_post_positions')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>展示策略：</label>
                                <select name="dictShowStrategy" th:with="type=${@dict.getType('dict_show_strategy')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>会员策略：</label>
                                <select name="dictVipStrategy" th:with="type=${@dict.getType('dict_vip_strategy')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>

                            <li>
                                <label>优惠券：</label>
                                <select name="dictIsCoupon" th:with="type=${@dict.getType('dict_is_coupon')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ecms:video:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ecms:video:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ecms:video:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ecms:video:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ecms:video:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ecms:video:remove')}]];
        var dictModuleTypeDatas = [[${@dict.getType('dict_module_type')}]];
        var dictPostPositionsDatas = [[${@dict.getType('dict_post_positions')}]];
        var dictShowStrategyDatas = [[${@dict.getType('dict_show_strategy')}]];
        var dictVipStrategyDatas = [[${@dict.getType('dict_vip_strategy')}]];
        var dictIsPackageDatas = [[${@dict.getType('dict_is_package')}]];
        var dictIsCouponDatas = [[${@dict.getType('dict_is_coupon')}]];
        var dictContentViewDatas = [[${@dict.getType('dict_content_view')}]];
        var prefix = ctx + "ecms/video";
        var prefixChapter = ctx + "ecms/chapter";
        var prefixVideo = ctx + "ecms/videoitems";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                addChapterUrl: prefixChapter + "/add?cmsVideoId={id}",
                listChapterUrl: prefixChapter + "/?cmsVideoId={id}",
                addVideoitemsUrl: prefixVideo + "/add?cmsVideoId={id}",
                listVideoitemsUrl: prefixVideo + "/?cmsVideoId={id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "录播课程",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '编号',
                    visible: false
                },
                {
                    field: 'categoryName',
                    title: '栏目'
                },
                {
                    field: 'title',
                    title: '标题'
                },
                
                {
                    field: 'videoTeacherName',
                    title: '授课讲师'
                },
                
                
                {
                    field: 'dictVipStrategy',
                    title: '会员策略',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(dictVipStrategyDatas, value);
                    }
                },
                {
                    field: 'dictIsPackage',
                    title: '套餐',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(dictIsPackageDatas, value);
                    }
                },
                {
                    field: 'dictIsCoupon',
                    title: '优惠券',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(dictIsCouponDatas, value);
                    }
                },
                {
                    field: 'maxPrice',
                    title: '市场价'
                },
                {
                    field: 'price',
                    title: '销售价'
                },
                {
                    field: 'saleNumber',
                    title: '销售数量'
                },
                {
                    field: 'sort',
                    title: '排序'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a>');
                        actions.push('  <a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<br/><br/>');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.addChapter(\'' + row.id + '\')"><i class="fa fa-edit"></i>章节添加</a>');
                        actions.push('  <a class="btn btn-info  btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.listChapter(\'' + row.id + '\')"><i class="fa fa-edit"></i>章节列表</a>');
                        actions.push('<br/><br/>');
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.addVideoitems(\'' + row.id + '\')"><i class="fa fa-edit"></i>视频添加</a>');
                        actions.push('  <a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.listVideoitems(\'' + row.id + '\')"><i class="fa fa-edit"></i>视频列表</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
    <script type="text/javascript">
    

    /*视频分类-编辑-选择父视频分类树*/
    function selectVideocategoryTree() {
        var options = {
            title: '视频分类选择',
            width: "380",
            url:  ctx + "ecms/videocategory" + "/selectVideocategoryTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }  
    </script>    
</body>
</html>